package com.shiyi.viewresolver;

import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.View;
import org.springframework.web.servlet.ViewResolver;

import java.util.Locale;

/**
 * @author wangzhanshuai
 * @date 2021/1/21 10:28 下午
 * @since 1.0
 */
@Order(1)
@Component
public class MyViewResolver implements ViewResolver, Ordered {

    private int order = 0;

    public void setOrder(int order) {
        this.order = order;
    }

    @Override
    public View resolveViewName(String viewName, Locale locale) throws Exception {
        if(viewName.startsWith("qiu")) {
            return new MyView();
        }
        return null;
    }

    @Override
    public int getOrder() {
        return order;
    }
}
